// @ts-ignore
/* eslint-disable */

import { request, type RequestOptions } from '@/utils/request';

/**
* products
* @param input
* @returns
*/
export async function products(input: ProductSearch, options?: RequestOptions) {
    return request<ProductSearchOut>(`product/products`, {
        method: 'POST',
        data: input,
        ...(options || {}),
    });
}
/**
* realDelete
* @param id:string
* @returns
*/
export async function realDelete(id: string, options?: RequestOptions) {
    return request<string>(`product/${id}/real-delete`, {
        method: 'POST',
        ...(options || {}),
    });
}
/**
* logicDelete
* @param id:string
* @returns
*/
export async function logicDelete(id: string, options?: RequestOptions) {
    return request<string>(`product/${id}/logic-delete`, {
        method: 'POST',
        ...(options || {}),
    });
}
/**
* get
* @param id:string
* @returns
*/
export async function get(id: string, options?: RequestOptions) {
    return request<ProductOut>(`product/${id}`, {
        method: 'GET',
        ...(options || {}),
    });
}
/**
* edit
* @param input
* @returns
*/
export async function edit(input: ProductOut, options?: RequestOptions) {
    return request<string>(`product/edit`, {
        method: 'POST',
        data: input,
        ...(options || {}),
    });
}
/**
* get
* @param key:string
* @returns
*/
export async function getGet(key: string, options?: RequestOptions) {
    return request<ProductOut>(`product`, {
        method: 'GET',
        params: { 'key': key },
        ...(options || {}),
    });
}
/**
* 获取所有产品分类
* @param params
* @returns
*/
export async function categories(params?: any, options?: RequestOptions) {
    return request<CategoryOut[]>(`category/categories`, {
        method: 'POST',
        data: params || {},
        ...(options || {}),
    });
}
/**
* 创建产品分类
* @param input
* @returns
*/
export async function createCategory(input: CategoryOut, options?: RequestOptions) {
    return request<string>(`category`, {
        method: 'POST',
        data: input,
        headers: {
            'Content-Type': 'application/json',
        },
        ...(options || {}),
    });
}
/**
* 编辑产品分类
* @param input
* @returns
*/
export async function editCategory(input: CategoryOut, options?: RequestOptions) {
    return request<string>(`category/${input.id}`, {
        method: 'PUT',
        data: input,
        headers: {
            'Content-Type': 'application/json',
        },
        ...(options || {}),
    });
}
/**
* 删除产品分类
* @param id:string
* @returns
*/
export async function deleteCategory(id: string, options?: RequestOptions) {
    return request<string>(`category/${id}`, {
        method: 'DELETE',
        ...(options || { successMsg: '删除成功' }),
    });
}

/**
* 获取所有产品
* @param key:string
* @param categoryId:string
* @returns
*/
export async function all(key: string, categoryId?: string, options?: RequestOptions) {
    return request<ProductOut[]>(`product/all`, {
        method: 'GET',
        params: { key, categoryId },
        ...(options || {}),
    });
}
